package com.qianli.cashmama.product.facade.enums;

import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by xuyang on 2017/7/18.
 */
public enum BusinessRuleTypeEnum {

    QUOTA("Quota rule", "QUOTA"),                   // 额度规则
    RISK_INFO("Risk data rule", "RISK_INFO"),       // 风控资料规则
    AUDIT("Audit rule", "AUDIT");                   // 审查规则


    private String name;
    private String code;

    BusinessRuleTypeEnum(String name, String code) {
        this.name = name;
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public String getCode() {
        return code;
    }

    public BusinessRuleTypeEnum getByCode(String code) {
        return ProductRuleTypeMapper.map.get(code);
    }

    private static class ProductRuleTypeMapper {
        private static ConcurrentHashMap<String, BusinessRuleTypeEnum> map = new ConcurrentHashMap<>();
        static {
            for (BusinessRuleTypeEnum type: BusinessRuleTypeEnum.values()) {
                map.put(type.getCode(), type);
            }
        }
    }
}
